<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/js-test.js"></script>
</head>

<body>
<table id="testTable" summary="A summary to make sure this is always exposed as an AXTable">
  <tr><td>foo</td></tr>
  <tr><td>bar</td></tr>
</table>

<p id="description"></p>
<div id="console"></div>
<script>
description("This tests that retrieving a cell for a table multiple times doesn't crash.");

if (window.testRunner) {
  testRunner.dumpAsText();

  if (window.accessibilityController) {
      var axTable = accessibilityController.accessibleElementById("testTable");
    shouldBe("axTable.role", "'AXRole: AXTable'");

    // Trying to reference the same cell for the table
    // multiple times shouldn't result in a crash.
    for (var i = 0; i < 10; i++) {
      var axCell = axTable.cellForColumnAndRow(0, 0);
      shouldBe("axCell.role", "'AXRole: AXCell'");
      axCell = null;

      // We need to force a call to the Garbage Collector here so we are
      // sure that axCell will get actually destroyed after using it.
      gc();
    }
  }
}
</script>

</body>
</html>
